#include "city.hpp"
#include "city_history_dialog.hpp"
#include "foreach.hpp"
#include "line_chart_widget.hpp"

namespace game_dialogs {

city_history_dialog::city_history_dialog(world& w, city_ptr c)
  : dialog(0, 0, 1024, 768), world_(w), city_(c)
{
	init();
}

void city_history_dialog::init()
{
	clear();

	using namespace gui;

	set_padding(30);

	line_chart_widget* history_chart = new line_chart_widget;
	history_chart->set_dim(500, 300);

	std::vector<int> population;
	foreach(const city::history_entry& entry, city_->history()) {
		population.push_back(entry.influence);
	}
	history_chart->add_plot(population);
	add_widget(widget_ptr(history_chart), 20, 20);
}
}
